package run.siyuan.jdk.设计模式.单例模式.单例模式案例1;

/**
 * @className: Singleton
 * @Description: TODO 单例模式：确保一个类只有一个实例
 * @author: siyuan
 * @date: 2022/3/11 1:58 PM
 */
public class Singleton {

    private static Singleton instance = new Singleton();

    public Singleton() {
    }

    public static Singleton getInstance() {
        return instance;
    }

    public void doSomething() {
        System.out.println(instance);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            System.out.println(Singleton.getInstance());
        }
    }

}
